package com.phison.fenestrapro.dashboard.data;

import java.io.Serializable;
import java.util.Hashtable;

import com.phison.fenestrapro.dashboard.util.GlobalConstants;

/**
 *
 * 
 * @author Niall O'Hara
 *
 */
public class Daylighting implements Serializable, GlobalConstants {

	private static final long serialVersionUID = 1L;
	
	private Hashtable<String, Hashtable<String, double[]>> tableSelector = new Hashtable<String, Hashtable<String, double[]>>(2);
	private Hashtable<String, Double> diffuseTransmittanceTable = new Hashtable<String, Double>(18);
	private Hashtable<String, Double> reflectanceTable = new Hashtable<String, Double>(3);
	private Hashtable<String, double[]> maintenanceFactorRes = new Hashtable<String, double[]>(3);
	private Hashtable<String, double[]> maintenanceFactorCom = new Hashtable<String, double[]>(3);
	private Hashtable<String, double[]> maintenanceFactorPol = new Hashtable<String, double[]>(3);
	
	/**
	 *
	 */
	public Daylighting() {
		
		diffuseTransmittanceTable.put(ST_DG_12_a_nc, 0.76d);
		diffuseTransmittanceTable.put(ST_DG_12_a_le_hc, 0.73d);
		diffuseTransmittanceTable.put(ST_DG_12_a_le_sc, 0.75d);
		diffuseTransmittanceTable.put(ST_DG_12_ar_le_sc, 0.75d);
		diffuseTransmittanceTable.put(ST_DG_16_a_nc, 0.78d);
		diffuseTransmittanceTable.put(ST_DG_16_a_le_sc, 0.76d);
		diffuseTransmittanceTable.put(ST_DG_16_ar_le_hc, 0.74d);
		diffuseTransmittanceTable.put(ST_DG_16_ar_le_sc, 0.76d);
		diffuseTransmittanceTable.put(ST_DG_16_ar_li_sc, 0.8d);
		diffuseTransmittanceTable.put(ST_DG_18_ar_le_sc, 0.795d);
		diffuseTransmittanceTable.put(ST_DG_16_ar_sc_le_sc, 0.61d);
		diffuseTransmittanceTable.put(ST_DG_16_ar_sc_cg, 0.55d);
		diffuseTransmittanceTable.put(ST_DG_16_ar_sc_sc, 0.55d);
		diffuseTransmittanceTable.put(ST_TG_12_ar_le_hc, 0.66d);
		diffuseTransmittanceTable.put(ST_TG_12_ar_le_sc, 0.71d);
		diffuseTransmittanceTable.put(ST_TG_16_ar_le_hc, 0.66d);
		diffuseTransmittanceTable.put(ST_TG_16_ar_le_sc, 0.71d);
		diffuseTransmittanceTable.put(ST_TG_12_k_le_sc, 0.71d);
		diffuseTransmittanceTable.put(ST_TG_12_k_li, 0.71d);
		
		reflectanceTable.put(REF_LW, 0.6d);
		reflectanceTable.put(REF_MW, 0.5d);
		reflectanceTable.put(REF_DW, 0.4d);
		
		tableSelector.put(BT_DOM, maintenanceFactorRes);
		tableSelector.put(BT_RES, maintenanceFactorRes);
		tableSelector.put(BT_OFF, maintenanceFactorCom);
		tableSelector.put(BT_RET, maintenanceFactorCom);
		tableSelector.put(BT_EDU, maintenanceFactorCom);
		tableSelector.put(BT_HOS, maintenanceFactorCom);
		tableSelector.put(BT_LEI, maintenanceFactorPol);
		
		maintenanceFactorRes.put(LS_RUR, new double[] {0.96d});
		maintenanceFactorRes.put(LS_SUB, new double[] {0.96d});
		maintenanceFactorRes.put(LS_URB, new double[] {0.92d});
		
		maintenanceFactorCom.put(LS_RUR, new double[] {0.96d});
		maintenanceFactorCom.put(LS_SUB, new double[] {0.96d});
		maintenanceFactorCom.put(LS_URB, new double[] {0.92d, 0.91d, 0.90d, 0.89d, 0.88d});
		
		maintenanceFactorPol.put(LS_RUR, new double[] {0.88d, 0.87d, 0.86d, 0.85d, 0.84d, 0.83d, 0.82d, 0.81d, 0.80d, 0.79d, 0.78d, 0.77d, 0.76d});
		maintenanceFactorPol.put(LS_SUB, new double[] {0.88d, 0.87d, 0.86d, 0.85d, 0.84d, 0.83d, 0.82d, 0.81d, 0.80d, 0.79d, 0.78d, 0.77d, 0.76d});
		maintenanceFactorPol.put(LS_URB, new double[] {0.88d, 0.87d, 0.86d, 0.85d, 0.84d, 0.83d, 0.82d, 0.81d, 0.80d, 0.79d, 0.78d, 0.77d, 0.76d});
		
	}
	
	/**
	 *
	 */
	public double getMaintenanceFactor(String buildingType, String locationSetting, int arrayPos) {
		Hashtable<String, double[]> table = tableSelector.get(buildingType);
		double[] values = table.get(locationSetting);
		return values[arrayPos];
	}
	
	/**
	 *
	 */
	public double getDiffuseTransmittance(String diffuseTransmittanceText) {
		double diffuseTransmittance = diffuseTransmittanceTable.get(diffuseTransmittanceText);
		return diffuseTransmittance;	
	}

	/**
	 *
	 */
	public double getReflectance(String reflectanceText) {
		double reflectance = reflectanceTable.get(reflectanceText);
		return reflectance;
	}

}
